using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using THSLib;
using System.Data;
namespace THSERP.BaseProvider
{
    public partial class THSTabControl : DevExpress.XtraTab.XtraTabControl
    {
        #region Variables
        protected THSERPScreen _screen;
        protected String _THSFieldGroup;
        protected String _THSComment;
        protected String _THSError;
        protected String _THSPrivilege;
        #endregion

        #region Public properties
        public THSERPScreen Screen
        {
            get
            {
                return _screen;
            }
            set
            {
                _screen = value;
            }
        }

        [Category("THS")]
        public String THSFieldGroup
        {
            get
            {
                return _THSFieldGroup;
            }
            set
            {
                _THSFieldGroup = value;
            }
        }

        [Category("THS")]
        public String THSComment
        {
            get
            {
                return _THSComment;
            }
            set
            {
                _THSComment = value;
            }
        }

        [Category("THS")]
        public String THSError
        {
            get
            {
                return _THSError;
            }
            set
            {
                _THSError = value;
            }
        }

        [Category("THS")]
        public String THSPrivilege
        {
            get
            {
                return _THSPrivilege;
            }
            set
            {
                _THSPrivilege = value;
            }
        }
        #endregion

        #region Constructor
        public THSTabControl()
        {
            InitializeComponent();
        }

        public THSTabControl(IContainer container)
        {
            container.Add(this);

            InitializeComponent();
        }
        #endregion

        #region--Initialize--
        public void InitializeControl()
        {
            //Init Columns for lookup Edit
            STFieldsInfo objSTFieldsInfo = new STFieldsController().GetFieldBySTModuleIDAndSTUserGroupIDAndSTFieldName(
                                                            ((BaseModuleERP)Screen.Module).ModuleID, THSApp.CurrentUserGroupInfo.ADUserGroupID,
                                                            this.Name);
            STFieldColumnsController objSTFieldColumnsController = new STFieldColumnsController();
            DataSet dsFieldColumns = objSTFieldColumnsController.GetAllDataByForeignColumn("STFieldID", objSTFieldsInfo.STFieldID);
            if (dsFieldColumns.Tables.Count > 0)
            {
                
                foreach (DataRow rowFieldColumn in dsFieldColumns.Tables[0].Rows)
                {
                    STFieldColumnsInfo objSTFieldColumnsInfo = (STFieldColumnsInfo)objSTFieldColumnsController.GetObjectFromDataRow(rowFieldColumn);
                    if (objSTFieldColumnsInfo != null)
                    {
                        DevExpress.XtraTab.XtraTabPage tabPage = new DevExpress.XtraTab.XtraTabPage();
                        tabPage.Name = objSTFieldColumnsInfo.STFieldColumnName;
                        tabPage.Width = objSTFieldColumnsInfo.STFieldColumnWidth;
                        tabPage.Text = objSTFieldColumnsInfo.STFieldColumnCaption;
                        this.TabPages.Add(tabPage);
                    }
                }
            }
            dsFieldColumns.Dispose();
            this.KeyUp += new KeyEventHandler(((BaseModuleERP)Screen.Module).Control_KeyUp);
        }
        #endregion
    }
}
